﻿Imports System.Data.SqlClient
Public Class LoginForm3
    Public con As String = "Data Source=gerenciamento.mssql.somee.com;packet size=4096;user id=loez_SQLLogin_1;pwd=7p7lqlrs4b;data source=gerenciamento.mssql.somee.com;persist security info=False;initial catalog=gerenciamento"
    Public sqlcon As New SqlConnection(con)
    Dim A As String
    Public Function Crypt(ByVal Text As String) As String
        Dim strTempChar As String
        For i = 1 To Len(Text)
            If Asc(Mid$(Text, i, 1)) < 128 Then
                strTempChar = Asc(Mid$(Text, i, 1)) + 128
            ElseIf Asc(Mid$(Text, i, 1)) > 128 Then
                strTempChar = Asc(Mid$(Text, i, 1)) - 128
            End If
            Mid$(Text, i, 1) = Chr(strTempChar)
        Next i
        Crypt = Text
    End Function
    Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
        Me.Close()
    End Sub
    Private Sub LoginForm3_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        loginTextBox.Focus()
        Try
            sqlcon.Open()
            ToolStripStatusLabel1.Text = ToolStripStatusLabel1.Text & "Online"
        Catch ex As Exception
            sqlcon.Close()
            ToolStripStatusLabel1.Text = ToolStripStatusLabel1.Text & "Offiline"
            loginTextBox.Enabled = False
            senhaTextBox.Enabled = False
            OK.Enabled = False
        End Try
    End Sub

    Private Sub senhaTextBox_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles senhaTextBox.LostFocus
        OK.Focus()
    End Sub
    Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
        Dim A As String
        If loginTextBox.Text = "" Or senhaTextBox.Text = "" Then
            MsgBox("FAVOR INFORMAR LOGIN/SENHA")
        Else
            If loginTextBox.Text = "LUIZ" Then
                LoginTableAdapter.FillByLOGIN(LOGINDataSet.Login, loginTextBox.Text, senhaTextBox.Text)
            Else
                senhaTextBox.Text = Crypt(senhaTextBox.Text)
                LoginTableAdapter.FillByLOGIN(LOGINDataSet.Login, loginTextBox.Text, senhaTextBox.Text)
            End If
        End If
        If LOGINDataSet.Tables(0).Rows.Count > 0 Then
            A = loginTextBox.Text
            If Date.Now.Day = 14 And Date.Now.Month = 11 Then
                MsgBox("PARABÉNS CLÁUDIA")
            ElseIf Date.Now.Day = 3 And Date.Now.Month = 2 Then
                MsgBox("PARABÉNS CRISTIANO")
            ElseIf Date.Now.Day = 13 And Date.Now.Month = 2 Then
                MsgBox("PARABÉNS KELLY")
            ElseIf Date.Now.Day = 5 And Date.Now.Month = 6 Then
                MsgBox("PARABÉNS ADELAINE")
            ElseIf Date.Now.Day = 6 And Date.Now.Month = 7 Then
                MsgBox("PARABÉNS DANIELA")
            ElseIf Date.Now.Day = 6 And Date.Now.Month = 11 Then
                MsgBox("PARABÉNS JANAINA")
            ElseIf Date.Now.Day = 28 And Date.Now.Month = 9 Then
                MsgBox("PARABÉNS LUIZ")
            ElseIf Date.Now.Day = 21 And Date.Now.Month = 9 Then
                MsgBox("PARABÉNS MAX")
            ElseIf Date.Now.Day = 22 And Date.Now.Month = 12 Then
                MsgBox("PARABÉNS FABIANE")
            End If
            PRINCIPAL.ToolStripLabel2.Text = "Online como: " & A
            Me.Hide()
            PRINCIPAL.Show()
            If A = "JANAINA" Or A = "LUIZ" Or A = "CRISTIANO" Then
                PRINCIPAL.USUÁRIOSToolStripMenuItem.Enabled = True
                SOLICITACAO.DELETAR.Enabled = True
                ATRASOS.DELETAR.Enabled = True
                ALINEAS.DELETAR.Enabled = True
                DOCUMENTACAO.DELETAR.Enabled = True
                LIMITES.DELETAR.Enabled = True
                ATRASOS.OBSRichTextBox.ReadOnly = False
                LIQUIDEZ.DELETAR.Enabled = True
            Else
                PRINCIPAL.USUÁRIOSToolStripMenuItem.Enabled = False
                SOLICITACAO.DELETAR.Enabled = False
                ALINEAS.DELETAR.Enabled = False
                DOCUMENTACAO.DELETAR.Enabled = False
                LIMITES.DELETAR.Enabled = False
                ATRASOS.OBSRichTextBox.ReadOnly = True
                LIQUIDEZ.DELETAR.Enabled = False
            End If
        Else
            MsgBox("FAVOR VERIFICAR SEU LOGIN ")
        End If
    End Sub
End Class
